<div class="top-banner-wrapper">
    <div class="logo"></div>
    <div class="phone-number-wrapper">
        <div class="phone-number">
            HCM: 0903 815 299 &#124; HN: 0936 197 528
            <div class="opening-closing-time">Open : 7:30 AM &#124; Close: 16:30 PM</div>
        </div>
    </div>
    <?php include_once("service/productService.php");?>
    <div class="favourite-cart-wrapper">
        <div class="favourite-wrapper">
        	<div class="favourite-icon"><?php echo getTotalLike(isset($_SESSION["userid"])?$_SESSION["userid"]:0); ?></div>
	        <div class="favourite-list-wrapper"></div>
        </div>
        <div class="cart-wrapper">
            <div id="numPro">
            	<?php
					if(isset($_SESSION["cart"])) 
						echo "(".count($_SESSION["cart"]).")";
					else if(!isset($_SESSION["cart"]) || count($_SESSION["cart"]) == 0)
						echo "(0)";
                ?>
            </div>
            <div class="cart-icon-wrapper">
                <div class="cart-icon" onclick="window.location.href = 'profile-cart.php#cart-tab';">GIỎ HÀNG</div>
            </div>
        </div>
    </div>
</div>
<script>
function unlikeProduct(proid,userid){
    $.ajax({
		type: "GET",
		url: "./action/ajax/unlikeProduct.php",
        data: { proid:proid, userid:userid },
        async:false
	}).done(function(data){
	   var numOfLike = $(".favourite-icon").html();
	   $(".favourite-icon").html(--numOfLike);
        $.ajax({
    		type: "GET",
    		url: "./action/ajax/getFavouriteProductProcess.php",
            async:false
    	}).done(function(data){
    	   cur_content = $(".favourite-list-wrapper").find(".mCSB_container").html();
                if(cur_content != null){
                    $(".favourite-list-wrapper").show();                
                    $(".favourite-list-wrapper").find(".mCSB_container").empty();
            		$(".favourite-list-wrapper").find(".mCSB_container").html(data);
        			$(".favourite-list-wrapper").find(".mCSB_scrollTools").css("right", "20px");
        			$(".favourite-list-wrapper").mCustomScrollbar("update");
                    $(".favourite-list-wrapper").hide();                
                }else{
                   $(".favourite-list-wrapper").show();
        	       $(".favourite-list-wrapper").html(data);
                   $(".favourite-list-wrapper").mCustomScrollbar();
                   $(".favourite-list-wrapper").hide();                        
            }
            
                    try
                      {
                        $.ajax({
                            type: "GET",
                            url: "./action/ajax/getLatestProduct.php",
                            data: { p: p,user:userid }
                        }).done(function( data ) {
                            $(".index-product-wrapper").empty();
                            $(".index-product-wrapper").html(data);
                            $(".product-price").each(function(){
                                var price = $(this).html();
                                $(this).html(formatCurrency(price,2));
                            }); 
                        });
                        
                        $.ajax({
                            type: "GET",
                            url: "./action/ajax/getProduct.php",
                            data: { p: p,c:c,user:userid }
                        }).done(function( data ) {
                            $(".index-product-wrapper").html(data);
                            $(".product-price").each(function(){
                                var price = $(this).html();
                                $(this).html(formatCurrency(price,2));
                            }); 
                        });
                      }
                   catch(err)
                      {
                      
                      }               
    	});        
	});
}
</script>